#pragma once
#include "HashBucket.hpp"
namespace lw
{
	template<class K, class V, class Hash = Hash<K>, class Equal = Equal<K>>
	class unordered_map
	{
		struct MapKOfT
		{
			const K& operator()(const std::pair<K, V>& kv) const
			{
				return kv.first;
			}
		};
	public:
		typedef typename lw::HashBucket<K, std::pair<K, V>, MapKOfT, Hash, Equal>::iterator iterator;
		iterator begin()
		{
			return _hash.begin();
		}
		iterator end()
		{
			return _hash.end();
		}
		std::pair<iterator, bool> insert(const std::pair<K, V>& kv)
		{
			return _hash.Insert(kv);
		}
		V& operator[](const K& key)
		{
			return insert(std::make_pair(key, V())).first->second;
		}
		bool erase(const K& key)
		{
			return _hash.Erase(key);
		}
		iterator find(const K& key)
		{
			return _hash.Find(key);
		}
	private:
		lw::HashBucket<K, std::pair<K, V>, MapKOfT, Hash, Equal> _hash;
	};
}